/*
 * Copyright (c)  2017
 * All rights reserved.
 * LotteryEntity.java 2017-09-17 下午2:07
 */

package com.ueboot.weishop.entity.lottery;

import com.ueboot.weishop.entity.IDEntity;
import com.ueboot.weishop.entity.customer.CustomerCouponEntity;
import com.ueboot.weishop.entity.customer.CustomerInfoEntity;
import com.ueboot.weishop.entity.order.OrderEntity;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.GenericGenerator;

import javax.persistence.*;

/**
 * 描述:中奖记录表
 * 保存所有抽奖成功的记录
 *
 * @author yangkui create on 2017-09-17 下午2:07.
 * @since 1.0
 */
@Data
@NoArgsConstructor
@Entity(name = "WS_LOTTERY_RECORD")
public class LotteryRecordEntity extends IDEntity {
    public static final String WIN_TYPE_0="代金券";
    @Id
    @GeneratedValue(strategy = GenerationType.TABLE, generator = "WS_LOTTERY_RECORD")
    @GenericGenerator(name = "WS_LOTTERY_RECORD", strategy = "enhanced-table", parameters = {
            @org.hibernate.annotations.Parameter(name = "table_name", value = "WS_TABLE_SEQUENCE"),
            @org.hibernate.annotations.Parameter(name = "segment_value", value = "WS_LOTTERY_RECORD"),
            @org.hibernate.annotations.Parameter(name = "optimizer", value = "pooled")})
    @Column(name = "ID", columnDefinition = "INT(20) COMMENT 'id主键'", length = 20)
    private Long id;


    //--中奖内容。可以是直接打折、或者减去金额、免单

    /**
     * 中奖结果类型（只可同时有一种）：打折|减去金额|免单|发放优惠券
     */
    @Column(name = "WIN_TYPE",columnDefinition = "VARCHAR(40) COMMENT '中奖结果类型'",length = 40)
    private String winType;

    /**
     * 折扣值，具体的折扣值，采用【1-10】
     */
    @Column(name = "DISCOUNT_VALUE",columnDefinition = "INT(11) COMMENT '折扣值，具体的折扣值，采用【1-10】'",length = 11)
    private Integer discountValue;
    /**
     * 折扣，直接减去的价格(单位分)
     */
    @Column(name = "DISCOUNT_MINUS_PRICE",columnDefinition = "INT(11) COMMENT '折扣，直接减去的价格(单位分)'",length = 11)
    private Integer discountMinusPrice;

    /**
     * 是否免单
     */
    @Column(name = "FREE",columnDefinition = "INT(1) COMMENT '是否免单'",length = 1)
    private Boolean free;

    /**
     * 发送给客户的优惠券。
     */
    @ManyToOne
    @JoinColumn(name="CUSTOMER_COUPON_ID",columnDefinition = "INT(20) COMMENT '发送给客户的优惠券'")
    private CustomerCouponEntity customerCoupon;
    /**
     * 关联的订单
     */
    @ManyToOne
    @JoinColumn(name="ORDER_ID",columnDefinition = "INT(20) COMMENT '关联的订单'")
    private OrderEntity order;

    /**
     * 关联的抽奖规则信息表
     */
    @ManyToOne
    @JoinColumn(name="lottery_ID",columnDefinition = "INT(20) COMMENT '关联的抽奖规则信息表'")
    private LotteryInfoEntity lottery;

    /**
     * 关联的客户信息
     */
    @ManyToOne
    @JoinColumn(name="CUSTOMER_ID",columnDefinition = "INT(20) COMMENT '关联的客户信息'")
    private CustomerInfoEntity customer;

    /**
     * 扩展状态，由其他业务逻辑处理，比如是否已经下发其他系统
     */
    @Column(name = "EXT_STATUS", columnDefinition = "INT(11) COMMENT ' 扩展状态，由其他业务逻辑处理，比如是否已经下发其他系统'", length = 11)
    private Integer extStatus;

    /**
     * 活动代码
     */
    @Column(name = "CATEGORY_CODE", columnDefinition = "VARCHAR(200) COMMENT ''", length = 200)
    private String categoryCode;


}